In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import gamma
from scipy.special import gamma as g
from scipy.special import gammaincc
from math import factorial, exp
from itertools import permutations, combinations
from sklearn.metrics.pairwise import rbf_kernel, laplacian_kernel
%matplotlib inline
In [2]:
import sys
sys.path.insert(0, '/Users/mati/Devel/dsga1005/code')
from independence_test import *
from r_independence import *
In [3]:
size = 2000
X_1 = np.random.rand(size)
Y_1 = np.random.randn(size)
In [4]:
test_ind = HSIC_b(X_1, Y_1, kernel='exponential')
In [5]:
test_ind.empirical_test()
Out[5]:
In [6]:
test_ind.p_value
Out[6]:
In [7]:
test_ind_r = dHSIC(X_1, Y_1)
In [28]:
print test_ind_r.res
In [8]:
test_ind_r.statistic
Out[8]:
In [9]:
test_ind_r.p_value
Out[9]:
In [18]:
size = 200
X_2 = np.random.normal(0,10,size)
Y_2 = X_2
In [19]:
test_non = HSIC_b(X_2, Y_2, kernel='exponential')
In [20]:
test_non.empirical_test()
Out[20]:
In [21]:
test_non.p_value
Out[21]:
In [22]:
test_non_r = dHSIC(X_2, Y_2)
In [29]:
print test_non_r.res
In [23]:
test_non_r.statistic
Out[23]:
In [24]:
test_non_r.p_value
Out[24]:
In [3]:
SIZE = 500
Z = np.random.randn(SIZE) * 100
X = Z + np.random.randn(SIZE)
Y = Z + np.random.randn(SIZE)
Z_vars = np.array(['Z'])
data = pd.DataFrame(np.array([X, Y, Z]).T, columns=["X", "Y", "Z"])
In [4]:
ci = CI('X', 'Y', ['Z'], data, 'cor')
In [6]:
ci.statistic
Out[6]:
In [7]:
ci.p_value
Out[7]:
In [8]:
SIZE = 500
Z = np.random.randn(SIZE) * 100
X = np.random.randn(SIZE)
Y = X
Z_vars = np.array(['Z'])
data = pd.DataFrame(np.array([X, Y, Z]).T, columns=["X", "Y", "Z"])
In [9]:
ci = CI('X', 'Y', ['Z'], data, 'cor')
In [11]:
ci.statistic
Out[11]:
In [12]:
ci.p_value
Out[12]:
In [ ]: